(* stack.pp *)

unit stack;

interface

const
   STACK_SIZE = 256;

type
   info= record
	     typ     : ShortString;
	     wartosc : real;
	  end;

var
   head	: integer;
   s	: array[1..STACK_SIZE] of info;

procedure push(item : info);
function pop() : info;

implementation

   procedure push(item : info);
   begin
      if head = STACK_SIZE then
      begin
	 writeln('error: stack overflow!');
	 exit;
      end
      else
      begin
	 s[head] := item;
	 head := head+1;
      end;
   end;

   function pop() : info;
   begin
      if head = 0 then
      begin
	 writeln('error	: stack underflow!');
	 exit;
      end
      else
begin
 head := head-1;
pop :=	s[head];
end;
   end;

end.

